<%@ page language="java" contentType="text/html"  pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div class="form-group">
	<label class="col-xs-3 control-label">
		父栏目：
	</label>
	<div class="col-xs-9">
		<input class="form-control" id="parentId" value="${pid}" name="pid" type="text" attribute="unempty +integer"
		placeholder="请输入父级部门ID">
	</div>
</div>	
<script>	
$(function(){
	function checkname(did){
		$.get("getDepartNameById?did="+did,function(res){
			if(res==0){
				myform.error("parentId","不存在该部门！");
			}else{
				myform.success("parentId",res);
			}			
		});
	}
	var parentId=myform.getValue("parentId");
	if(parentId==0){
		myform.success("parentId","顶级部门");
	}else{
		checkname(parentId);
	}
	$("#parentId").blur(function(){
		var t=Number($(this).val());
		if(!isNaN(t)){
			checkname(t);
		}else{
			myform.error("parentId","请输入整数！");
		}	
	});
});
</script>								